#!/bin/bash
# 作用：启/停Flume采集通道（日志数据 -> Kafka）
if [ $# -ne 1 ]
then
	echo "请输入正确的指令start/stop" && exit
fi

FLUME_HOME=/opt/module/flume-1.9.0

case $1 in
"start")
	for host in hadoop102 hadoop103
	do
		echo "========== 启动$host的日志采集 =========="
		ssh $host "$FLUME_HOME/bin/flume-ng agent -n a1 -c $FLUME_HOME/conf/ -f $FLUME_HOME/job/file_to_kafka_log.conf -Dflume.root.logger=INFO,LOGFILE >$FLUME_HOME/logs/flume.log 2>&1 &"
	done
;;
"stop")
	for host in hadoop102 hadoop103
	do
		echo "========== 关闭$host的日志采集 =========="
		ssh $host "ps -ef | grep file_to_kafka_log.conf | grep -v grep | awk '{print \$2}' | xargs kill -9"
	done
;;
*)
	echo "请输入正确的指令start/stop" && exit
;;
esac